//This class should probably extend Serial. 
// Just not sure I want to do that yet.

//Empty packet condition is -1 for each byte in the packet.

#ifndef _ROBOT_CLI_
#define _ROBOT_CLI_

#include "WProgram.h"

struct cmd_lst
{
	//18 bytes, 8 integer values, needs to be the same as packet size below 
	int packet[ 8 ];
	unsigned char nodeNum;
	struct cmd_lst* next;
};

typedef struct cmd_lst* node;

class Robot_CLI
{
	public:

		//Constructors
		Robot_CLI();

		//Initializer -- Takes responsibility of constructor because
		//in the Arduino environment, constructors act funny.
		void startComm( int speed = 9600 ); //Duplicates Serial.begin()
		
		//Client methods
		int getCommand( int commandRef[], const unsigned int size,
					const unsigned char token = ' ' ); 
		int sendCommand( int commandRef[], const unsigned int size, 
					const unsigned char token = ' ' );	
		void sendCmdLog( const unsigned char token = ' ' );
		//Left this here for debugging.
		//void _delCmdLst();

	private:

		//Utility methods
		bool _establishContact();
		void _delCmdLst();

		//Data
		node _head;
		node _current;
		node _tail;
		static const unsigned int _cmd_lst_size = 128;
		static const unsigned int _packet_size = 8;
};

#endif
